Skip to content

Add ParparVM annotations to disable debug and safety checks for hot Base64 methods#4732

Merged
liannacasper merged 14 commits intomasterfrom
codex/add-annotations-to-disable-parparvm-checks
Apr 11, 2026
Merged

Add ParparVM annotations to disable debug and safety checks for hot Base64 methods#4732
liannacasper merged 14 commits intomasterfrom
codex/add-annotations-to-disable-parparvm-checks

Conversation

@liannacasper
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a way to selectively disable ParparVM emitted debug info and runtime array/null checks for performance-sensitive methods.
  • Target hotspot Base64 encoding/decoding routines to measure the effect of disabling those checks.

Description

  • Add two method-level annotations: com.codename1.annotations.DisableDebugInfo and com.codename1.annotations.DisableNullChecksAndArrayBoundsChecks to mark methods for reduced ParparVM emission.
  • Wire the Parser to detect those annotations during method visit and set per-method flags on BytecodeMethod via setDisableDebugInfo and setDisableNullAndArrayBoundsChecks.
  • Honor the flags during code emission so LineNumber no longer emits __CN1_DEBUG_INFO(...) when debug info is disabled and array load/store code (and ArrayLoadExpression) skip CHECK_ARRAY_ACCESS(...) / CHECK_ARRAY_ACCESS_WITH_ARGS(...) when null/array-bounds checks are disabled.
  • Annotate hot Base64 methods (decode(byte[],int,byte[]), decodeNoWhitespace(...), encodeNoNewline(...)) with the new annotations and add translator unit tests asserting suppression of debug and array-check emissions.

Testing

  • Ran the ParparVM translator unit suite test BytecodeInstructionIntegrationTest with mvn -pl tests -am -Dtest=BytecodeInstructionIntegrationTest -Dsurefire.failIfNoSpecifiedTests=false test and it passed: 31 tests, 0 failures.
  • Tried mvn -pl tests -Dtest=BytecodeInstructionIntegrationTest test without reactor build flags and also tried invoking Maven with a Java 8 JAVA_HOME; those invocations initially failed due to environment-specific setup (missing JAVA_HOME path or missing module artifact), but the full translator test run above completed successfully.

Codex Task

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 10, 2026

Android screenshot updates

Compared 36 screenshots: 35 matched, 1 updated.

  • ValidatorLightweightPicker — updated screenshot. Screenshot differs (320x640 px, bit depth 8).

    ValidatorLightweightPicker
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as ValidatorLightweightPicker.png in workflow artifacts.

Native Android coverage

  • 📊 Line coverage: 7.79% (4094/52579 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.10% (20207/331490), branch 2.93% (937/31974), complexity 3.63% (1113/30622), method 6.37% (911/14300), class 10.50% (199/1896)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 920.000 ms
Base64 CN1 encode 125.000 ms
Base64 encode ratio (CN1/native) 0.136x (86.4% faster)
Base64 native decode 859.000 ms
Base64 CN1 decode 194.000 ms
Base64 decode ratio (CN1/native) 0.226x (77.4% faster)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 381 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10507 ms

  • Hotspots (Top 20 sampled methods):

    • 23.62% java.lang.String.indexOf (442 samples)
    • 17.96% com.codename1.tools.translator.Parser.isMethodUsed (336 samples)
    • 13.68% java.util.ArrayList.indexOf (256 samples)
    • 6.41% com.codename1.tools.translator.Parser.addToConstantPool (120 samples)
    • 4.28% java.lang.Object.hashCode (80 samples)
    • 4.12% com.codename1.tools.translator.ByteCodeClass.markDependent (77 samples)
    • 2.99% java.lang.System.identityHashCode (56 samples)
    • 1.66% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (31 samples)
    • 1.60% com.codename1.tools.translator.BytecodeMethod.equals (30 samples)
    • 1.39% com.codename1.tools.translator.BytecodeMethod.optimize (26 samples)
    • 1.23% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (23 samples)
    • 1.18% com.codename1.tools.translator.Parser.getClassByName (22 samples)
    • 1.18% java.lang.StringCoding.encode (22 samples)
    • 1.07% java.lang.StringBuilder.append (20 samples)
    • 1.02% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (19 samples)
    • 0.75% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (14 samples)
    • 0.75% sun.nio.fs.UnixNativeDispatcher.open0 (14 samples)
    • 0.69% com.codename1.tools.translator.Parser.cullMethods (13 samples)
    • 0.69% java.util.ArrayList$Itr.next (13 samples)
    • 0.59% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (11 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 10, 2026

Compared 36 screenshots: 36 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 93 seconds

Detailed Performance Metrics

Metric Duration
Simulator Boot 0 ms
Simulator Boot (Run) 0 ms
App Install 2000 ms
App Launch 6000 ms
Test Execution 146000 ms
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 899.000 ms
Base64 CN1 encode 1176.000 ms
Base64 encode ratio (CN1/native) 1.308x (30.8% slower)
Base64 native decode 684.000 ms
Base64 CN1 decode 942.000 ms
Base64 decode ratio (CN1/native) 1.377x (37.7% slower)

@liannacasper liannacasper merged commit 22eb74f into master Apr 11, 2026
20 of 22 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: 1 issue(s) flagged (1 errors) (exit code 1) (report)
  • Vale: 18621 alert(s) (2704 errors, 6359 warnings, 9558 suggestions) (exit code 1) (report)
  • Image references: 33 unused image(s) found (report)

Unused image preview:

  • img/uwp-app-manager-apps.png
  • img/uwp-certificate-generator.png
  • img/uwp-cn1settings-debug-desktop-selected.png
  • img/uwp-cn1settings-disk-icon.png
  • img/uwp-cn1settings-uwp.png
  • img/uwp-cn1settings-windows-settings-menu-item.png
  • img/uwp-dashboard-download-appxbundle.png
  • img/uwp-extract-zip-file.png
  • img/uwp-mobile-recently-added.png
  • img/uwp-mobile-settings-developer-mode.png
  • ... and 23 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants